%Parameters of the channel generator
f0 = 1;
f1 = 0.5;
F = [f0,f1];
mu0 = 0.8;
mu1 = 0.2;
MUcoef = [mu0,mu1];
t = 0:0.01:0.09;
%MU0 = mu0 * (1+0.8*cos(2*pi*f0*t)); % T = 1 sec
%MU1 = mu1 * (1+0.8*cos(2*pi*f1*t + 0.3)); % T = 2 sec

% MU = zeros(2,size(t,2))
% for i = 1 : size(t,2)
%     MU(:,i) = genMu(t(1,i),F,2);
% end
% MU
% figure(1); plot(t,MU(1,:),'-')
% figure(2); plot(t,MU(2,:),'-')

% test Signal
T1 = 1;
T2 = 1;
T3 = -1;
%           x0 x1 x2 T1 T2 T3 x3 x4 x5
CodeWord = [-1, 1,-1,T1,T2,T3, 1, 1, 1];
%            1, 2, 3, 4, 5, 6, 7, 8, 9

Channel = zeros(1,length(CodeWord));

Channel(1,1)=CodeWord(1,1)*genMu(t(1,1),f0,1);
for i = 2:length(CodeWord)
    Channel(1,i)=CodeWord(1,i)*genMu(t(1,i),f0,1) + CodeWord(1,i-1)*genMu(t(1,i),f1,1);
end

Channel

% Try to estimate channel coeffs
A = [T2 T1
    T3 T2];
f = [Channel(1,5); Channel(1,6)];
MuEst = A\f % Estimated channel coeffs mu0 mu1